﻿using System;
using System.Collections.Generic;
using System.Text;

namespace SAWPOS
{
    class CVSImporter
    {
        public CVSImporter()
        {
        }

        #region Public Methods
        public void SelectFile()
        {
            System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog();
            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            openFileDialog.Filter = "Archivo separado por comas(*.csv)|*.csv";
            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string FileName = openFileDialog.FileName;
                System.IO.StreamReader lector = new System.IO.StreamReader(FileName);
                string lectura = lector.ReadLine();
                lector.Close();
                FormularioImportador importador = new FormularioImportador();
                importador.ListaCampos = lectura.Split(',');
                importador.Show();
                importador.MostrarCamposImportacion();
                importador.RutaArchivoImportacion = FileName;
            }
        }
        #endregion
    }
}
